package com.whmskj.xjlhsc.view.controller;

import com.whmskj.xjlhsc.controller.vo.Result;
import com.whmskj.xjlhsc.entity.YsWbRecord;
import com.whmskj.xjlhsc.service.Sb02EquipmentCounterAccountService;
import com.whmskj.xjlhsc.service.YsWbRecordService;
import com.whmskj.xjlhsc.view.entity.vo.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 张
 * @version 1.0
 */

@RestController
@RequestMapping("/api/view/device")
@Slf4j
@Tag(description = "设备看板", name = "设备看板")
public class DeviceViewController {
    @Autowired
    private Sb02EquipmentCounterAccountService sb02EquipmentCounterAccountService;
    @Autowired
    private YsWbRecordService ysWbRecordService;

    @GetMapping("getDevicesState")
    @Operation(description = "设备状态")
    public Result getDevicesState(@RequestParam(required = false) String process) {
        List<StateVo> map = sb02EquipmentCounterAccountService.getDevicesState(process);
        return Result.success(map);
    }

    @Operation(description = "今日维保任务")
    @GetMapping("MaintenanceTaskToday")
    public Result MaintenanceTaskToday() {
        List<MaintenanceTaskVo> list = ysWbRecordService.MaintenanceTaskToday();
        return Result.success(list);
    }

    @Operation(description = "各工序维保次数")
    @GetMapping("processMaintenanceNum")
    public Result processMaintenanceNum(@RequestParam String dateType) {
        List<ProcessMaintenanceNumVo> list = ysWbRecordService.processMaintenanceNum(dateType);
        return Result.success(list);
    }

    @GetMapping("deviceRunEfficiency")
    @Operation(description = "设备运行效率")
    public Result deviceRunEfficiency(@RequestParam String dateType) {
        List<Map<String,Object>> list = sb02EquipmentCounterAccountService.deviceRunEfficiency(dateType);
        return Result.success(list);
    }

    @GetMapping("classesRunEfficiency")
    @Operation(description = "班组运行效率")
    public Result classesRunEfficiency(@RequestParam String startTime, @RequestParam String endTime) {
        List<HashMap<String, Object>> list = sb02EquipmentCounterAccountService.classesRunEfficiency(startTime, endTime);
        return Result.success(list);
    }
}
